<template>
  <div class="cart-list-item">
    <div class="check-button">
      <check-botton :isChecked="product.checked" @click.native="checkClick" />
    </div>

    <div class="item-img">
      <img :src="product.image" alt="商品图片" />
    </div>

    <div class="item-info">
      <div class="info-title">{{ product.title }}</div>
      <div class="info-desc">{{ product.desc }}</div>
      <div class="info-bottom">
        <div class="bottom-price">¥{{ product.price }}</div>
        <div class="bottom-count">X{{ product.count }}</div>
      </div>
    </div>
  </div>
</template>

<script>
import CheckBotton from "../../../components/content/checkBotton/CheckBotton.vue";
export default {
  name: "CartListItem",
  components: {
    CheckBotton,
  },
  props: {
    product: {
      type: Object,
      default() {
        return {};
      },
    },
  },
  methods: {
    checkClick() {
      this.product.checked = !this.product.checked;
    },
  },
};
</script>

<style>
.cart-list-item {
  display: flex;
  padding: 5px;
  width: 100%;
}
.check-button {
  width: 20px;
}
.item-img {
  flex: 1;
  padding: 0 10px 0 5px;
}
.item-img img {
  width: 100px;
  height: 100px;
}
.item-info {
  flex: 1;
  position: relative;
}
.info-title {
  width: 250px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 22px;
}
.info-desc {
  width: 240px;
  margin-top: 10px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 16px;
}
.info-bottom {
  position: absolute;
  bottom: 10px;
  right: 10px;
  left: 10px;
}
.bottom-price {
  float: left;
  font-size: 22px;
  color: #ff5777;
}
.bottom-count {
  float: right;
  margin-right: 20px;
}
</style>